const express = require('express');
const router = express.Router();

/**
 * @param {Object} options
 * @param {} options.brandId 品牌
 * @param {} options.code 货代编号
 * @param {} options.name 货代名称
 * @param {} options.shortName 货代简称
 * @param {} options.status 状态  1-生效  -1-作废
 * @param {} options.pageSize 每页数据量
 * @param {} options.pageIndex 指定页
 * @param {} options.sortField 排序字段
 * @param {} options.isDesc 倒序排列
 * @throws {Error}
 * @return {Promise}
 */
router.get('/forPartShipOrder', async(req, res, next) => {
    const options = {
        brandId: req.query.brandId,
        code: req.query.code,
        name: req.query.name,
        shortName: req.query.shortName,
        status: req.query.status,
        pageSize: req.query.pageSize,
        pageIndex: req.query.pageIndex,
        sortField: req.query.sortField,
        isDesc: req.query.isDesc
    };
    const data = {
        message: 'message',
        payload: {
            content: [
                {
                    id: 'id164',
                    fax: 'fax',
                    code: 'code165',
                    name: 'name166',
                    status: 1,
                    contactId: 'contactId167',
                    contact: 'contact',
                    contactNumber: 'contactNumber'
                },
                {
                    id: 'id168',
                    fax: 'fax',
                    code: 'code169',
                    name: 'name170',
                    status: 1,
                    contactId: 'contactId171',
                    contact: 'contact',
                    contactNumber: 'contactNumber'
                }
            ],
            pageIndex: null,
            pageSize: null,
            sort: null,
            totalElements: 50,
            totalPages: null
        }
    };
    res.json(data);
});
router.get('/', (req, res) => {
    const content = [];
    for(let i = 0; i < 40; i++) content.push({
        id: `${i + 1}`,
        code: `201900${i}`,
        name: `JXSMC00${i}`,
        brandName: 'chery',
        shortName: 'string',
        status: 1,
        rowVersion: 'string',
        options: [
            'abandon',
            'update'
        ]
    });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 40,
        }
    });
});
router.get('/forCBUSaleOrder', (req, res) => {
    const content = [];
    for(let i = 0; i < 10; i++) content.push({
        id: `${i + 1}`,
        code: `201900${i}`,
        name: `JXSMC00${i}`,
    });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 40,
        }
    });
});
router.get('/:id', (req, res) => {
    res.json(
        {
            message: 'string',
            payload: {
                id: '1',
                code: '2019001',
                name: 'JXSMC001',
                brandId: 'chery',
                brandCode: 'brandCode',
                brandName: 'brandName',
                shortName: 'string',
                status: 1,
                rowVersion: 'string',
                options: [
                    'update',
                    'abandon',
                ],
                details: [
                    {
                        id: 'string',
                        contact: 'string',
                        contactNumber: 'string',
                        fax: 'string',
                        email: 'string',
                        remark: 'string'
                    }
                ]
            }
        }
    );
});
router.get('/forSaleProformaInvoice', (req, res) => {
    const content = [];
    for(let i = 0; i < 10; i++) content.push({
        id: `${i + 1}`,
        code: `201900${i}`,
        name: `JXSMC00${i}`,
    });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 40,
        }
    });
});
router.post('/', (req, res) => {
    res.json({
        message: '新增成功'
    });
});

router.put('/:id', (req, res) => {
    res.json({
        message: '编辑成功'
    });
});

router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '作废成功'
    });
});

module.exports = router;
